# -*- coding: latin-1 -*-
import pygtk
pygtk.require('2.0')
import gtk
import querys as query

class Login:

    def destroy(self, widget, data=None):
        gtk.main_quit()
    
    def open_loja (self, widget, none):
        start_loja()
        self.w_login.destroy()

    def open_admin (self, widget, none):
        start_admin()
        self.w_login.destroy()

    def __init__(self):
        self.w_login = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.w_login.connect("delete_event", lambda w,e: gtk.main_quit())
        self.w_login.set_title("CEF SHOP - Login")
        self.w_login.set_size_request(250,150)
        self.w_login.set_border_width(20)

#-------Botoes       
        
        button_loja = gtk.Button("Loja")
        button_loja.connect("clicked", self.open_loja, None)
        
        button_admin = gtk.Button("Administração")
        button_admin.connect("clicked", self.open_admin, None)
        
#------Divisao h principal

        hbox_main = gtk.HBox(True, 2)
        self.w_login.add(hbox_main)     

#------Frame escolha

        frame_escolha = gtk.Frame("Escolha")
        hbox_main.pack_start(frame_escolha, True, True, 2)

        vbox_escolha=gtk.VButtonBox()
        vbox_escolha.set_layout(gtk.BUTTONBOX_SPREAD)
        vbox_escolha.set_spacing(10)
        frame_escolha.add(vbox_escolha)
        
        vbox_escolha.add(button_admin)
        vbox_escolha.add(button_loja)

        self.w_login.show_all()
        self.w_login.show()
    
#------------------------------------------------------------------

class Loja:

    def open_cad_clientes (self, widget, none):
        cad_clientes()
    
    def open_locar(self, widget):
        locar()

    def open_devolver(self, widget):
        devolver()

    def __init__(self):
        self.w_loja = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.w_loja.connect("delete_event", lambda w,e: gtk.main_quit())
        self.w_loja.set_title("CEF SHOP - Loja")
        self.w_loja.set_size_request(500,200)
        self.w_loja.set_border_width(20)

#---Botoes
        button_clientes = gtk.Button("Clientes")
        button_clientes.connect("clicked", self.open_cad_clientes, None)

        button_retirada = gtk.Button("Retirada")
        button_retirada.connect("clicked",self.open_locar)
       
        button_devolucao = gtk.Button("Devolução")
        button_devolucao.connect("clicked",self.open_devolver)
       
        button_venda = gtk.Button("Venda")
        #button_venda.connect("clicked", , None)

#------Divisao h principal

        hbox_main = gtk.HBox(True, 2)
        self.w_loja.add(hbox_main)     

#------Divisoes v dos elementos 
       
        vbox1 = gtk.VBox(True, 2)
        hbox_main.pack_start(vbox1, True, True, 0)

        vbox2 = gtk.VBox(True, 2)
        hbox_main.pack_start(vbox2, True, True, 0)

#------Frame cadastro

        frame_cad = gtk.Frame("Cadastro")
        vbox1.pack_start(frame_cad, True, True, 0)
        
        vbox_cad=gtk.VButtonBox()
        vbox_cad.set_layout(gtk.BUTTONBOX_SPREAD)
        vbox_cad.set_spacing(10)
        frame_cad.add(vbox_cad)
        
        vbox_cad.add(button_clientes)

#------Frame loja

        frame_loja = gtk.Frame("Loja")
        vbox1.pack_start(frame_loja, True, True, 0)
 
        vbox_loja=gtk.VButtonBox()
        vbox_loja.set_layout(gtk.BUTTONBOX_SPREAD)
        vbox_loja.set_spacing(10)
        frame_loja.add(vbox_loja)
        
        vbox_loja.add(button_venda)


#------Frame locacao
       
        frame_loca = gtk.Frame("Locação")
        vbox2.pack_start(frame_loca, True, True, 0)

        vbox_loca=gtk.VButtonBox()
        vbox_loca.set_layout(gtk.BUTTONBOX_SPREAD)
        vbox_loca.set_spacing(10)
        frame_loca.add(vbox_loca)
        
        vbox_loca.add(button_retirada)
        vbox_loca.add(button_devolucao)

#-------Mostra tudo

        self.w_loja.show_all()
        self.w_loja.show()

#----------------------------------------------------

class Cadastro_clientes:

    def close(self,w):
        self.w_cad_clientes.destroy()

    def cadastra (self, widget, entry_nome):
        name = entry_nome.get_text()       
        query.insert_cliente(name)
        show_popup()
        self.w_cad_clientes.destroy()
        
    def __init__(self):
        self.w_cad_clientes = gtk.Dialog()
        self.w_cad_clientes.set_size_request(500,200)
        self.w_cad_clientes.set_border_width(4)
        self.w_cad_clientes.set_title("CEF SHOP - Cadastro de Clientes")
        self.w_cad_clientes.connect("destroy", self.close)
     
#-------Elementos
       
        label_nome = gtk.Label("Nome :")
        entry_nome = gtk.Entry(0)

        label_cpf = gtk.Label("CPF :")
        entry_cpf = gtk.Entry(0)

        button_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        button_cancel.connect("clicked", self.close)
        button_ok = gtk.Button(stock=gtk.STOCK_OK)
        button_ok.connect("clicked", self.cadastra, entry_nome)
  
#------Frame Dados pessoais

        frame_dados = gtk.Frame("Dados Pessoais")
        self.w_cad_clientes.vbox.pack_start(frame_dados, True, True, 4)
      
        vbox_labelentry = gtk.HBox(False, 4)
        vbox_labelentry.set_border_width(4)
        frame_dados.add(vbox_labelentry)
        
        vbox_label = gtk.VBox(False, 4)
        vbox_labelentry.pack_start(vbox_label, False, True, 2)
       
        vbox_entry = gtk.VBox(False, 4)
        vbox_labelentry.pack_start(vbox_entry, True, True, 2)

        vbox_label.pack_start(label_nome, False, True, 8)
        vbox_entry.pack_start(entry_nome, False, True, 2)
        
        vbox_label.pack_start(label_cpf, False, True, 8)
        vbox_entry.pack_start(entry_cpf, False, True, 2)

#-------Botoes     

        bbox = gtk.HButtonBox ()
        bbox.set_layout(gtk.BUTTONBOX_END)
        self.w_cad_clientes.action_area.pack_start(bbox, False, True, 0)
        
        bbox.add(button_cancel)
        button_cancel.set_flags(gtk.CAN_DEFAULT)

        bbox.add(button_ok)
        button_cancel.grab_default()
          
#------Mostra tudo

        self.w_cad_clientes.show_all()
        self.w_cad_clientes.show()
           
#-----------------------------------------------------

class Admin:

    def open_generos(self, widget):
        generos()

    def open_filmes(self, widget):
        filmes()

    def open_locados(self, widget):
        locados()

    def open_atrasados(self, widget):
        atrasados()

    def __init__(self):
        self.w_admin = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.w_admin.connect("delete_event", lambda w,e: gtk.main_quit())
        self.w_admin.set_title("CEF SHOP - Administração")
        self.w_admin.set_size_request(500,200)
        self.w_admin.set_border_width(20)

#---Botoes
        button_generos = gtk.Button("Generos")
        button_generos.connect("clicked", self.open_generos)

        button_filmes = gtk.Button("Filmes")
        button_filmes.connect("clicked",self.open_filmes)
       
        button_locados = gtk.Button("Locados")
        button_locados.connect("clicked",self.open_locados)
       
        button_atrasados = gtk.Button("Atrasados")
        button_atrasados.connect("clicked",self.open_atrasados)

#------Divisao h principal

        hbox_main = gtk.HBox(True, 2)
        self.w_admin.add(hbox_main)     

#------Frame cadastro

        frame_cad = gtk.Frame("Cadastro")
        hbox_main.pack_start(frame_cad, True, True, 2)

        vbox_cad=gtk.VButtonBox()
        vbox_cad.set_layout(gtk.BUTTONBOX_SPREAD)
        vbox_cad.set_spacing(10)
        frame_cad.add(vbox_cad)
        
        vbox_cad.add(button_generos)
        vbox_cad.add(button_filmes)

#------Frame Controle

        frame_controle = gtk.Frame("Controle")
        hbox_main.pack_start(frame_controle, True, True, 2)
 
        vbox_controle=gtk.VButtonBox()
        vbox_controle.set_layout(gtk.BUTTONBOX_SPREAD)
        vbox_controle.set_spacing(10)
        frame_controle.add(vbox_controle)
        
        vbox_controle.add(button_locados)
        vbox_controle.add(button_atrasados)

#-------Mostra tudo

        self.w_admin.show_all()
        self.w_admin.show()

#-------------------------------------------------
class popup:

    def close(self,w):
        self.w_popup.destroy()

    def __init__(self):
        self.w_popup = gtk.Dialog()
        self.w_popup.connect("destroy", self.close)
        self.w_popup.set_title("CEF - SHOP - Dialog")
        self.w_popup.set_border_width(0)
        self.w_popup.set_size_request(300, 100)

        button_ok = gtk.Button(stock=gtk.STOCK_OK)
        button_ok.connect("clicked", self.close)
        self.w_popup.action_area.pack_start(button_ok, True, True, 0)
       
        label = gtk.Label("Registro gravado com sucesso!")
        self.w_popup.vbox.pack_start(label, True, True, 0)

        label.show()
        button_ok.show()
        self.w_popup.show()

#----------------------------------------

class Generos:
    
    def create_list(self):

        scrolled_window = gtk.ScrolledWindow()
        scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        lista = gtk.ListStore(int,str)
        tree_view = gtk.TreeView(lista)
        scrolled_window.add_with_viewport (tree_view)

        rows=query.select_all_generodvd()
        for row in rows:
            lista.append([row[0], row[1]])

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn("Cod", cell, text=0)
        
        cell2 = gtk.CellRendererText()
        column2 = gtk.TreeViewColumn("Descrição", cell2, text=1)
        
        tree_view.append_column(column)
        tree_view.append_column(column2)

        return scrolled_window

    def destroy(self, widget, data=None):
        gtk.main_quit()
    
    def close(self,w):
        self.w_generos.destroy()

    def cadastra (self, widget, entry_descricao):
        name = entry_descricao.get_text()       
        query.insert_generodvd(name)
        show_popup()
        self.w_generos.destroy()
       
    def __init__(self):
        self.w_generos = gtk.Dialog()
        self.w_generos.connect("destroy", self.close)
        self.w_generos.set_title("CEF SHOP - Cadastrar Generos")
        self.w_generos.set_size_request(450,250)
        self.w_generos.set_border_width(8)

#-------Elementos       
        
        label_descricao = gtk.Label("Descrição :")
        entry_descricao = gtk.Entry(0)
  
#------Lista
        vpaned = gtk.VPaned()
        self.w_generos.vbox.add(vpaned)

        frame_generos = gtk.Frame("Generos")
        vpaned.add(frame_generos)

        liststore = self.create_list()
        frame_generos.add(liststore)

#------Frame cadastra

        frame_dados = gtk.Frame("Cadastrar Novo Genero")
        self.w_generos.vbox.add(frame_dados)
      
        vbox_labelentry = gtk.HBox(False, 4)
        vbox_labelentry.set_border_width(4)
        frame_dados.add(vbox_labelentry)
        
        vbox_label = gtk.VBox(False, 4)
        vbox_labelentry.pack_start(vbox_label, False, True, 2)
       
        vbox_entry = gtk.VBox(False, 4)
        vbox_labelentry.pack_start(vbox_entry, True, True, 2)

        vbox_label.pack_start(label_descricao, False, True, 8)
        vbox_entry.pack_start(entry_descricao, False, True, 2)

#-------Botoes     

        button_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        button_cancel.connect("clicked", self.close)
        button_ok = gtk.Button(stock=gtk.STOCK_OK)
        button_ok.connect("clicked", self.cadastra, entry_descricao)

        bbox = gtk.HButtonBox ()
        bbox.set_layout(gtk.BUTTONBOX_END)
        self.w_generos.action_area.pack_start(bbox, False, True, 0)
        
        bbox.add(button_cancel)
        button_cancel.set_flags(gtk.CAN_DEFAULT)

        bbox.add(button_ok)
        button_cancel.grab_default()

        self.w_generos.show_all()
        self.w_generos.show()
#-----------------------------------------------------

class Filmes:
    
    def get_genero(self, widget, combo_genero, generos, entry_titulo, entry_quantidade):
        active = combo_genero.get_active()
        if active >= 0:   
            genero = generos[active][1]
            self.cadastra(genero, entry_titulo, entry_quantidade)

    def close(self,w):
        self.w_filmes.destroy()

    def cadastra (self, genero, entry_titulo, entry_quantidade):
        titulo = entry_titulo.get_text()
        quantidade =int(entry_quantidade.get_text())       
        cod_genero = query.select_generodvd(genero)
        print cod_genero[0][0]
        cod_filme = query.insert_filme(cod_genero[0][0], titulo, quantidade)

        for quant in range(quantidade):
            query.insert_dvd(cod_filme[0])

        show_popup()
        self.w_filmes.destroy()
       
    def __init__(self):
        self.w_filmes = gtk.Dialog()
        self.w_filmes.connect("destroy", self.close)
        self.w_filmes.set_title("CEF SHOP - Cadastrar Filmes")
        self.w_filmes.set_size_request(450,250)
        self.w_filmes.set_border_width(8)

#-------Elementos       
        
        label_titulo = gtk.Label("Titulo :")
        entry_titulo = gtk.Entry(0)

        label_genero = gtk.Label("Genero :")
        combo_genero = gtk.combo_box_new_text()
        generos=query.select_all_generodvd()
        for genero in generos:
            combo_genero.append_text(genero[1])

        label_quantidade = gtk.Label("Quantidade :")
        entry_quantidade = gtk.Entry(0)
     
        
#------Frame cadastra

        frame_dados = gtk.Frame("Dados do Filme")
        self.w_filmes.vbox.add(frame_dados)
      
        vbox_labelentry = gtk.HBox(False, 4)
        vbox_labelentry.set_border_width(4)
        frame_dados.add(vbox_labelentry)
        
        vbox_label = gtk.VBox(False, 4)
        vbox_labelentry.pack_start(vbox_label, False, True, 2)
       
        vbox_entry = gtk.VBox(False, 4)
        vbox_labelentry.pack_start(vbox_entry, True, True, 2)

        vbox_label.pack_start(label_titulo, False, True, 8)
        vbox_entry.pack_start(entry_titulo, False, True, 2)

        vbox_label.pack_start(label_genero, False, True, 8)
        vbox_entry.pack_start(combo_genero, False, True, 2)

        vbox_label.pack_start(label_quantidade, False, True, 8)
        vbox_entry.pack_start(entry_quantidade, False, True, 2)


#-------Botoes     

        button_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        button_cancel.connect("clicked", self.close)
        button_ok = gtk.Button(stock=gtk.STOCK_OK)
        button_ok.connect("clicked", self.get_genero, combo_genero, generos, entry_titulo, entry_quantidade)

        bbox = gtk.HButtonBox ()
        bbox.set_layout(gtk.BUTTONBOX_END)
        self.w_filmes.action_area.pack_start(bbox, False, True, 0)
        
        bbox.add(button_cancel)
        button_cancel.set_flags(gtk.CAN_DEFAULT)

        bbox.add(button_ok)
        button_cancel.grab_default()


        self.w_filmes.show_all()
        self.w_filmes.show()

#-----------------------------------------------------

class Locar:
    
    def close(self,w):
        self.w_locar.destroy()

    def cadastra (self,widget, entry_cliente, entry_dvd):
        cod_cliente = entry_cliente.get_text()
        cod_dvd = entry_dvd.get_text()       
        dias = '7'
        query.insert_locacao(cod_cliente, cod_dvd, dias)
        show_popup()
        self.w_locar.destroy()
       
    def __init__(self):
        self.w_locar = gtk.Dialog()
        self.w_locar.connect("destroy", self.close)
        self.w_locar.set_title("CEF SHOP - Locar")
        self.w_locar.set_size_request(450,250)
        self.w_locar.set_border_width(8)

#-------Elementos       
        
        label_cliente = gtk.Label("Codigo do Cliente :")
        entry_cliente = gtk.Entry(0)

        label_dvd = gtk.Label("Codigo do DvD :")
        entry_dvd = gtk.Entry(0)
     
#------Frame cadastra

        frame_dados = gtk.Frame("Locação")
        self.w_locar.vbox.add(frame_dados)
      
        vbox_labelentry = gtk.HBox(False, 4)
        vbox_labelentry.set_border_width(4)
        frame_dados.add(vbox_labelentry)
        
        vbox_label = gtk.VBox(False, 4)
        vbox_labelentry.pack_start(vbox_label, False, True, 2)
       
        vbox_entry = gtk.VBox(False, 4)
        vbox_labelentry.pack_start(vbox_entry, True, True, 2)

        vbox_label.pack_start(label_cliente, False, True, 8)
        vbox_entry.pack_start(entry_cliente, False, True, 2)

        vbox_label.pack_start(label_dvd, False, True, 8)
        vbox_entry.pack_start(entry_dvd, False, True, 2)

#-------Botoes     

        button_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        button_cancel.connect("clicked", self.close)
        button_ok = gtk.Button(stock=gtk.STOCK_OK)
        button_ok.connect("clicked", self.cadastra, entry_cliente, entry_dvd)

        bbox = gtk.HButtonBox ()
        bbox.set_layout(gtk.BUTTONBOX_END)
        self.w_locar.action_area.pack_start(bbox, False, True, 0)
        
        bbox.add(button_cancel)
        button_cancel.set_flags(gtk.CAN_DEFAULT)

        bbox.add(button_ok)
        button_cancel.grab_default()


        self.w_locar.show_all()
        self.w_locar.show()

#-----------------------------------------------------

class Devolver:
    
    def close(self,w):
        self.w_devolver.destroy()

    def cadastra (self, widget, entry_dvd):
        cod_dvd = int(entry_dvd.get_text())       
        cods = query.select_locados()
        for cod in cods:
            if (cod_dvd == cod[1]):
                query.insert_devolucao(cod[0])
                show_popup()
                break
        self.w_devolver.destroy()
       
    def __init__(self):
        self.w_devolver = gtk.Dialog()
        self.w_devolver.connect("destroy", self.close)
        self.w_devolver.set_title("CEF SHOP - Locar")
        self.w_devolver.set_size_request(450,250)
        self.w_devolver.set_border_width(8)

#-------Elementos       
        
        label_dvd = gtk.Label("Codigo do DvD :")
        entry_dvd = gtk.Entry(0)
     
#------Frame cadastra

        frame_dados = gtk.Frame("Devolução")
        self.w_devolver.vbox.add(frame_dados)
      
        vbox_labelentry = gtk.HBox(False, 4)
        vbox_labelentry.set_border_width(4)
        frame_dados.add(vbox_labelentry)
        
        vbox_label = gtk.VBox(False, 4)
        vbox_labelentry.pack_start(vbox_label, False, True, 2)
       
        vbox_entry = gtk.VBox(False, 4)
        vbox_labelentry.pack_start(vbox_entry, True, True, 2)

        vbox_label.pack_start(label_dvd, False, True, 8)
        vbox_entry.pack_start(entry_dvd, False, True, 2)

#-------Botoes     

        button_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        button_cancel.connect("clicked", self.close)
        button_ok = gtk.Button(stock=gtk.STOCK_OK)
        button_ok.connect("clicked", self.cadastra,entry_dvd)

        bbox = gtk.HButtonBox ()
        bbox.set_layout(gtk.BUTTONBOX_END)
        self.w_devolver.action_area.pack_start(bbox, False, True, 0)
        
        bbox.add(button_cancel)
        button_cancel.set_flags(gtk.CAN_DEFAULT)

        bbox.add(button_ok)
        button_cancel.grab_default()


        self.w_devolver.show_all()
        self.w_devolver.show()
#-----------------------------------------------------

class Locados:
    
    def close(self,w):
        self.w_locados.destroy()

    def create_list(self):

        scrolled_window = gtk.ScrolledWindow()
        scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        lista = gtk.ListStore(int, int, str, str)
        tree_view = gtk.TreeView(lista)
        scrolled_window.add_with_viewport (tree_view)

        rows=query.select_locados()
        for row in rows:
            lista.append([row[1], row[2], row[3], row[4]])

        cell1 = gtk.CellRendererText()
        column1 = gtk.TreeViewColumn("Cod Dvd", cell1, text=0)
        
        cell2 = gtk.CellRendererText()
        column2 = gtk.TreeViewColumn("Cod Cliente", cell2, text=1)
        
        cell3 = gtk.CellRendererText()
        column3 = gtk.TreeViewColumn("Retirada", cell3, text=2)
        
        cell4 = gtk.CellRendererText()
        column4 = gtk.TreeViewColumn("Devolver em", cell4, text=3)
        tree_view.append_column(column1)
        tree_view.append_column(column2)
        tree_view.append_column(column3)
        tree_view.append_column(column4)


        return scrolled_window
   
    def __init__(self):
        self.w_locados = gtk.Dialog()
        self.w_locados.connect("destroy", self.close)
        self.w_locados.set_title("CEF SHOP - Locados")
        self.w_locados.set_size_request(450,250)
        self.w_locados.set_border_width(8)

  
#------Lista
        vpaned = gtk.VPaned()
        self.w_locados.vbox.add(vpaned)

        frame_locados = gtk.Frame("Dvds atualmente Alugados ")
        vpaned.add(frame_locados)

        liststore = self.create_list()
        frame_locados.add(liststore)

#-------Botoes     

        button_close = gtk.Button(stock=gtk.STOCK_CLOSE)
        button_close.connect("clicked", self.close)
        
        bbox = gtk.HButtonBox ()
        bbox.set_layout(gtk.BUTTONBOX_END)
        self.w_locados.action_area.pack_start(bbox, False, True, 0)
        
        bbox.add(button_close)
        button_close.set_flags(gtk.CAN_DEFAULT)


        self.w_locados.show_all()
        self.w_locados.show()

#-----------------------------------------------------

class Atrasados:
    
    def close(self,w):
        self.w_atrasados.destroy()

    def create_list(self):

        scrolled_window = gtk.ScrolledWindow()
        scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        lista = gtk.ListStore(int, int, str, str)
        tree_view = gtk.TreeView(lista)
        scrolled_window.add_with_viewport (tree_view)

        rows=query.select_locados_atrasados()
        for row in rows:
            lista.append([row[1], row[2], row[3], row[4]])

        cell1 = gtk.CellRendererText()
        column1 = gtk.TreeViewColumn("Cod Dvd", cell1, text=0)
        
        cell2 = gtk.CellRendererText()
        column2 = gtk.TreeViewColumn("Cod Cliente", cell2, text=1)
        
        cell3 = gtk.CellRendererText()
        column3 = gtk.TreeViewColumn("Retirada", cell3, text=2)
        
        cell4 = gtk.CellRendererText()
        column4 = gtk.TreeViewColumn("Atrasado desde", cell4, text=3)
        tree_view.append_column(column1)
        tree_view.append_column(column2)
        tree_view.append_column(column3)
        tree_view.append_column(column4)


        return scrolled_window
   
    def __init__(self):
        self.w_atrasados = gtk.Dialog()
        self.w_atrasados.connect("destroy", self.close)
        self.w_atrasados.set_title("CEF SHOP - Locados")
        self.w_atrasados.set_size_request(450,250)
        self.w_atrasados.set_border_width(8)

  
#------Lista
        vpaned = gtk.VPaned()
        self.w_atrasados.vbox.add(vpaned)

        frame_locados = gtk.Frame("Dvds atualmente Alugados ")
        vpaned.add(frame_locados)

        liststore = self.create_list()
        frame_locados.add(liststore)

#-------Botoes     

        button_close = gtk.Button(stock=gtk.STOCK_CLOSE)
        button_close.connect("clicked", self.close)
        
        bbox = gtk.HButtonBox ()
        bbox.set_layout(gtk.BUTTONBOX_END)
        self.w_atrasados.action_area.pack_start(bbox, False, True, 0)
        
        bbox.add(button_close)
        button_close.set_flags(gtk.CAN_DEFAULT)


        self.w_atrasados.show_all()
        self.w_atrasados.show()
#-----------------------------------------------------

def start_loja():
    Loja()

def start_admin():
    Admin()

def show_popup():
    popup()

def cad_clientes():
    Cadastro_clientes()

def filmes():
    Filmes()

def locar():
    Locar()

def devolver():
    Devolver()

def generos():
    Generos()

def locados():
    Locados()

def atrasados():
    Atrasados()

def main():
    gtk.main()
    return 0
    
if __name__ == "__main__":
    query.connect()
    Login()
    main()
